/*河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
*/
package cn.javaxc.oa.action.communication;
import java.io.*;
import java.util.*;
import java.sql.*;
import cn.javaxc.model.base.SQL;
import cn.javaxc.model.base.SQLList;
import cn.javaxc.model.base.SQLMap;
import cn.javaxc.model.base.SQLParam;
import cn.javaxc.model.page.BatisPage;
import cn.javaxc.mvcwork.controller.web.TreeBean;
import cn.javaxc.mvcwork.util.common.CommonUtil;
import cn.javaxc.mvcwork.util.common.MapListUtil;
import cn.javaxc.mvcwork.util.helper.FrameHelper;
import cn.javaxc.mvcwork.util.helper.TreeTableHelper;
import org.springframework.beans.factory.annotation.Autowired;
import cn.javaxc.system.action.base.BaseAction;
import cn.javaxc.oa.mapper.communication.SmsMapper;
public class SmsAction extends BaseAction
{
    @Autowired(required=false)
	private SmsMapper mapper;
    /**
    新短信
    */
    
    public Map newSms() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> phones=mapper.phones(params);
        result.put("phones", phones);
        
        
        SQLList<SQLMap> contacts=mapper.contacts(params);
        result.put("contacts", contacts);
        
        
        SQLList<SQLMap> userids=mapper.userids(params);
        SQLMap userids_emt=userids.getExistfirst();
        result.put("userids", userids_emt);
        
        return result;
    }
    /**
    选择发送人
    */
    
    public Map phoneSendContactsChoice() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> s_client=mapper.s_client(params);
        result.put("s_client", s_client);
        
        return result;
    }
    /**
    选择客户电话号码
    */
    
    public Map phoneCustomerChoice() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.def("person_name",null);
        Object sname =mapper.sname(params);
        result.put("sname", sname);
        
        
        SQLList<SQLMap> s_phone=mapper.s_phone(params,pagination);
        s_phone.setPagedListInfo(pagination);
        result.put("s_phone", s_phone);
        
        
        params.def("s_type",-1);
        params.def("s_name","''");
        SQLList<SQLMap> s_type=mapper.s_type(params);
        SQLMap s_type_emt=s_type.getExistfirst();
        result.put("s_type", s_type_emt);
        
        return result;
    }
    /**
    选择联系人电话号码
    */
    
    public Map phoneContactsChoice() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.def("person_name",null);
        Object sname =mapper.sname(params);
        result.put("sname", sname);
        
        
        SQLList<SQLMap> s_phone=mapper.s_phone(params,pagination);
        s_phone.setPagedListInfo(pagination);
        result.put("s_phone", s_phone);
        
        
        params.def("s_type",-1);
        params.def("s_name","''");
        SQLList<SQLMap> s_type=mapper.s_type(params);
        SQLMap s_type_emt=s_type.getExistfirst();
        result.put("s_type", s_type_emt);
        
        return result;
    }
    /**
    选择员工电话号码
    */
    
    public Map phoneStaffChoice() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> s_user=mapper.s_user(params,pagination);
        s_user.setPagedListInfo(pagination);
        result.put("s_user", s_user);
        
        
        SQLList<SQLMap> s_type=mapper.s_type(params);
        SQLMap s_type_emt=s_type.getExistfirst();
        result.put("s_type", s_type_emt);
        
        return result;
    }
    /**
    选择发送的电话号码
    */
    
    public Map phoneSendChoice() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.def("s_type",-1);
        params.def("s_type",-1);
        SQLList<SQLMap> s_sclient=mapper.s_sclient(params,pagination);
        s_sclient.setPagedListInfo(pagination);
        result.put("s_sclient", s_sclient);
        
        
        params.def("s_type",-1);
        params.def("s_name","''");
        SQLList<SQLMap> s_type=mapper.s_type(params);
        SQLMap s_type_emt=s_type.getExistfirst();
        result.put("s_type", s_type_emt);
        
        return result;
    }
    /**
    选择短信常用语
    */
    
    public Map mesChoice() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.def("CMID",-1);
        SQLList<SQLMap> classid=mapper.classid(params);
        result.put("classid", classid);
        
        
        params.def("CMID",-1);
        SQLList<SQLMap> cate=mapper.cate(params);
        SQLMap cate_emt=cate.getExistfirst();
        result.put("cate", cate_emt);
        
        
        
        
        params.def("CMID",-1);
        SQLList<SQLMap> content=mapper.content(params);
        result.put("content", content);
        
        return result;
    }
    /**
    选择标签
    */
    
    public Map labelChoice() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> ss=mapper.ss(params);
        result.put("ss", ss);
        
        return result;
    }
    /**
    短信常用语
    */
    
    public Map commonSms() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.def("CMID",-1);
        SQLList<SQLMap> classid=mapper.classid(params);
        result.put("classid", classid);
        
        
        params.def("CMID",-1);
        SQLList<SQLMap> cate=mapper.cate(params);
        SQLMap cate_emt=cate.getExistfirst();
        result.put("cate", cate_emt);
        
        
        params.def("CMID",-1);
        SQLList<SQLMap> content=mapper.content(params);
        result.put("content", content);
        
        return result;
    }
    /**
    修改常用语类别
    */
    
    public Map mesPhraseCateUp() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> ss=mapper.ss(params);
        SQLMap ss_emt=ss.getExistfirst();
        result.put("ss", ss_emt);
        
        return result;
    }
    /**
    短信常用语明细
    */
    
    public Map mesPhraseDetailed() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> s=mapper.s(params);
        SQLMap s_emt=s.getExistfirst();
        result.put("s", s_emt);
        
        return result;
    }
    /**
    修改常用语
    */
    
    public Map mesPhraseUp() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> s=mapper.s(params);
        SQLMap s_emt=s.getExistfirst();
        result.put("s", s_emt);
        
        return result;
    }
    /**
    发短信箱
    */
    
    public Map sendSms() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> s_send=mapper.s_send(params);
        s_send.setSelectNone("发送情况明细");
        result.put("s_send", s_send);
        
        return result;
    }
    /**
    新短信修改
    */
    
    public Map newSmsSubmit() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        sendSMS(getParameter("number"),getParameter("phones_message"));
        
        
        for (SQLMap emt:SQL.foreach(getParameter("number"),"number","\n")){
            params=new SQLParam(request,emt.getMap());
            if(SQL.isNotNull(params.get("number")))
            mapper.i_recipient(params);
        }
        
        
        result.put("actionInfo", "发送成功");
        
        return result;
    }
    /**
    */
    
    public Map d_content() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        mapper.d_content(params);
        
        return result;
    }
    /**
    */
    
    public Map d_class() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        mapper.d_class(params);
        
        return result;
    }
    /**
    增加常用语类别修改
    */
    
    public Map mesPhraseCateAddSubmit() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.def("CMID",-1);
        int i = mapper.i(params);
        result.put("i", i);
        
        return result;
    }
    /**
    修改常用语类别修改
    */
    
    public Map mesPhraseCateUpSubmit() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        int i = mapper.i(params);
        result.put("i", i);
        
        return result;
    }
    /**
    增加常用短信内容修改
    */
    
    public Map mesDesAddSubmit() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        params.def("CMID",-1);
        int i = mapper.i(params);
        result.put("i", i);
        
        return result;
    }
    /**
    修改常用语修改
    */
    
    public Map mesPhraseUpSubmit() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        int u = mapper.u(params);
        result.put("u", u);
        
        return result;
    }
    /**
    */
    
    public Map d_cam() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        for (SQLMap emt:hqlBean.getTableElements("note_send")){
            params=new SQLParam(request,emt.getMap());
            mapper.d_cam(params);
        }
        
        return result;
    }
    /**
    发短信箱修改
    */
    
    public Map sendSmsSubmit() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        for (SQLMap emt:hqlBean.getTableElements("note_send")){
            params=new SQLParam(request,emt.getMap());
            mapper.d_note(params);
        }
        
        
        
        
        
        return result;
    }
}